home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / SCC.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  7KB  |  259 lines

  1. /* $Id: scc.h,v 1.29 1997/04/02 14:56:45 jreuter Exp jreuter $ */
  2.  
  3. #ifndef    _SCC_H
  4. #define    _SCC_H
  5.  
  6. #include <linux/config.h>
  7.  
  8. /* selection of hardware types */
  9.  
  10. #define PA0HZP        0x00    /* hardware type for PA0HZP SCC card and compatible */
  11. #define EAGLE             0x01    /* hardware type for EAGLE card */
  12. #define PC100        0x02    /* hardware type for PC100 card */
  13. #define PRIMUS        0x04    /* hardware type for PRIMUS-PC (DG9BL) card */
  14. #define DRSI        0x08    /* hardware type for DRSI PC*Packet card */
  15. #define BAYCOM        0x10    /* hardware type for BayCom (U)SCC */
  16.  
  17. /* DEV ioctl() commands */
  18.  
  19. enum SCC_ioctl_cmds {
  20.     SIOCSCCRESERVED = SIOCDEVPRIVATE,
  21.     SIOCSCCCFG,
  22.     SIOCSCCINI,
  23.     SIOCSCCCHANINI,
  24.     SIOCSCCSMEM,
  25.     SIOCSCCGKISS,
  26.     SIOCSCCSKISS,
  27.     SIOCSCCGSTAT,
  28.     SIOCSCCCAL
  29. };
  30.  
  31. /* magic number */
  32.  
  33. #define SCC_MAGIC    0x8530        /* ;-) */
  34.  
  35. /* Device parameter control (from WAMPES) */
  36.  
  37. enum L1_params {
  38.     PARAM_DATA,
  39.     PARAM_TXDELAY,
  40.     PARAM_PERSIST,
  41.     PARAM_SLOTTIME,
  42.     PARAM_TXTAIL,
  43.     PARAM_FULLDUP,
  44.     PARAM_SOFTDCD,        /* was: PARAM_HW */
  45.     PARAM_MUTE,        /* ??? */
  46.     PARAM_DTR,
  47.     PARAM_RTS,
  48.     PARAM_SPEED,
  49.     PARAM_ENDDELAY,        /* ??? */
  50.     PARAM_GROUP,
  51.     PARAM_IDLE,
  52.     PARAM_MIN,
  53.     PARAM_MAXKEY,
  54.     PARAM_WAIT,
  55.     PARAM_MAXDEFER,
  56.     PARAM_TX,
  57.     PARAM_HWEVENT = 31,
  58.     PARAM_RETURN = 255    /* reset kiss mode */
  59. };
  60.  
  61. /* fulldup parameter */
  62.  
  63. enum FULLDUP_modes {
  64.     KISS_DUPLEX_HALF,    /* normal CSMA operation */
  65.     KISS_DUPLEX_FULL,    /* fullduplex, key down trx after transmission */
  66.     KISS_DUPLEX_LINK,    /* fullduplex, key down trx after 'idletime' sec */
  67.     KISS_DUPLEX_OPTIMA    /* fullduplex, let the protocol layer control the hw */
  68. };
  69.  
  70. /* misc. parameters */
  71.  
  72. #define TIMER_OFF    65535U    /* to switch off timers */
  73. #define NO_SUCH_PARAM    65534U    /* param not implemented */
  74.  
  75. /* HWEVENT parameter */
  76.  
  77. enum HWEVENT_opts {
  78.     HWEV_DCD_ON,
  79.     HWEV_DCD_OFF,
  80.     HWEV_ALL_SENT
  81. };
  82.  
  83. /* channel grouping */
  84.  
  85. #define RXGROUP        0100    /* if set, only tx when all channels clear */
  86. #define TXGROUP        0200    /* if set, don't transmit simultaneously */
  87.  
  88. /* Tx/Rx clock sources */
  89.  
  90. enum CLOCK_sources {
  91.     CLK_DPLL,    /* normal halfduplex operation */
  92.     CLK_EXTERNAL,    /* external clocking (G3RUH/DF9IC modems) */
  93.     CLK_DIVIDER,    /* Rx = DPLL, Tx = divider (fullduplex with */
  94.             /* modems without clock regeneration */
  95.     CLK_BRG        /* experimental fullduplex mode with DPLL/BRG for */
  96.             /* MODEMs without clock recovery */
  97. };
  98.  
  99. /* Tx state */
  100.  
  101. enum TX_state {
  102.     TXS_IDLE,    /* Transmitter off, no data pending */
  103.     TXS_BUSY,    /* waiting for permission to send / tailtime */
  104.     TXS_ACTIVE,    /* Transmitter on, sending data */
  105.     TXS_NEWFRAME,    /* reset CRC and send (next) frame */
  106.     TXS_IDLE2,    /* Transmitter on, no data pending */
  107.     TXS_WAIT,    /* Waiting for Mintime to expire */
  108.     TXS_TIMEOUT    /* We had a transmission timeout */
  109. };
  110.  
  111. typedef unsigned long io_port;    /* type definition for an 'io port address' */
  112.  
  113. /* SCC statistical information */
  114.  
  115. struct scc_stat {
  116.         long rxints;            /* Receiver interrupts */
  117.         long txints;            /* Transmitter interrupts */
  118.         long exints;            /* External/status interrupts */
  119.         long spints;            /* Special receiver interrupts */
  120.  
  121.         long txframes;          /* Packets sent */
  122.         long rxframes;          /* Number of Frames Actually Received */
  123.         long rxerrs;            /* CRC Errors */
  124.         long txerrs;        /* KISS errors */
  125.         
  126.     unsigned int nospace;    /* "Out of buffers" */
  127.     unsigned int rx_over;    /* Receiver Overruns */
  128.     unsigned int tx_under;    /* Transmitter Underruns */
  129.  
  130.     unsigned int tx_state;    /* Transmitter state */
  131.     int tx_queued;        /* tx frames enqueued */
  132.  
  133.     unsigned int maxqueue;    /* allocated tx_buffers */
  134.     unsigned int bufsize;    /* used buffersize */
  135. };
  136.  
  137. struct scc_modem {
  138.     long speed;        /* Line speed, bps */
  139.     char clocksrc;        /* 0 = DPLL, 1 = external, 2 = divider */
  140.     char nrz;        /* NRZ instead of NRZI */    
  141. };
  142.  
  143. struct scc_kiss_cmd {
  144.     int       command;    /* one of the KISS-Commands defined above */
  145.     unsigned param;        /* KISS-Param */
  146. };
  147.  
  148. struct scc_hw_config {
  149.     io_port data_a;        /* data port channel A */
  150.     io_port ctrl_a;        /* control port channel A */
  151.     io_port data_b;        /* data port channel B */
  152.     io_port ctrl_b;        /* control port channel B */
  153.     io_port vector_latch;    /* INTACK-Latch (#) */
  154.     io_port    special;    /* special function port */
  155.  
  156.     int    irq;        /* irq */
  157.     long    clock;        /* clock */
  158.     char    option;        /* command for function port */
  159.  
  160.     char brand;        /* hardware type */
  161.     char escc;        /* use ext. features of a 8580/85180/85280 */
  162. };
  163.  
  164. /* (#) only one INTACK latch allowed. */
  165.  
  166.  
  167. struct scc_mem_config {
  168.     unsigned int dummy;
  169.     unsigned int bufsize;
  170. };
  171.  
  172. struct scc_calibrate {
  173.     unsigned int time;
  174.     unsigned char pattern;
  175. };
  176.  
  177. #ifdef __KERNEL__
  178.  
  179. enum {TX_OFF, TX_ON};    /* command for scc_key_trx() */
  180.  
  181. /* Vector masks in RR2B */
  182.  
  183. #define VECTOR_MASK    0x06
  184. #define TXINT        0x00
  185. #define EXINT        0x02
  186. #define RXINT        0x04
  187. #define SPINT        0x06
  188.  
  189. #ifdef CONFIG_SCC_DELAY
  190. #define Inb(port)    inb_p(port)
  191. #define Outb(port, val)    outb_p(val, port)
  192. #else
  193. #define Inb(port)    inb(port)
  194. #define Outb(port, val)    outb(val, port)
  195. #endif
  196.  
  197. /* SCC channel control structure for KISS */
  198.  
  199. struct scc_kiss {
  200.     unsigned char txdelay;        /* Transmit Delay 10 ms/cnt */
  201.     unsigned char persist;        /* Persistence (0-255) as a % */
  202.     unsigned char slottime;        /* Delay to wait on persistence hit */
  203.     unsigned char tailtime;        /* Delay after last byte written */
  204.     unsigned char fulldup;        /* Full Duplex mode 0=CSMA 1=DUP 2=ALWAYS KEYED */
  205.     unsigned char waittime;        /* Waittime before any transmit attempt */
  206.     unsigned int  maxkeyup;        /* Maximum time to transmit (seconds) */
  207.     unsigned char mintime;        /* Minimal offtime after MAXKEYUP timeout (seconds) */
  208.     unsigned int  idletime;        /* Maximum idle time in ALWAYS KEYED mode (seconds) */
  209.     unsigned int  maxdefer;        /* Timer for CSMA channel busy limit */
  210.     unsigned char tx_inhibit;    /* Transmit is not allowed when set */    
  211.     unsigned char group;        /* Group ID for AX.25 TX interlocking */
  212.     unsigned char mode;        /* 'normal' or 'hwctrl' mode (unused) */
  213.     unsigned char softdcd;        /* Use DPLL instead of DCD pin for carrier detect */
  214. };
  215.  
  216.  
  217. /* SCC channel structure */
  218.  
  219. struct scc_channel {
  220.     int magic;            /* magic word */
  221.     
  222.     int init;            /* channel exists? */
  223.  
  224.     struct device *dev;        /* link to device control structure */
  225.     struct net_device_stats dev_stat;/* device statistics */
  226.  
  227.     char brand;            /* manufacturer of the board */
  228.     long clock;            /* used clock */
  229.     
  230.     io_port ctrl;            /* I/O address of CONTROL register */
  231.     io_port    data;            /* I/O address of DATA register */
  232.     io_port special;        /* I/O address of special function port */
  233.     int irq;            /* Number of Interrupt */
  234.     
  235.     char option;
  236.     char enhanced;            /* Enhanced SCC support */
  237.  
  238.     unsigned char wreg[16];     /* Copy of last written value in WRx */
  239.     unsigned char status;        /* Copy of R0 at last external interrupt */
  240.     unsigned char dcd;        /* DCD status */
  241.  
  242.         struct scc_kiss kiss;        /* control structure for KISS params */
  243.         struct scc_stat stat;        /* statistical information */
  244.         struct scc_modem modem;     /* modem information */
  245.         
  246.         struct sk_buff_head tx_queue;    /* next tx buffer */
  247.         struct sk_buff *rx_buff;    /* pointer to frame currently received */
  248.         struct sk_buff *tx_buff;    /* pointer to frame currently transmitted */
  249.  
  250.     /* Timer */
  251.  
  252.     struct timer_list tx_t;        /* tx timer for this channel */
  253.     struct timer_list tx_wdog;    /* tx watchdogs */
  254. };
  255.  
  256. int scc_init(void);
  257. #endif /* defined(__KERNEL__) */
  258. #endif /* defined(_SCC_H) */
  259.